package com.xjgc.eip.twice.zxjeip2czzjc.service.impl;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.jeecg.common.api.vo.Result;
import org.springframework.stereotype.Service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjgc.common.constant.Consants;
import com.xjgc.eip.twice.zxjeip2czzjc.entity.ZxjEip2cZzjc;
import com.xjgc.eip.twice.zxjeip2czzjc.mapper.ZxjEip2cZzjcMapper;
import com.xjgc.eip.twice.zxjeip2czzjc.service.ZxjEip2cZzjcService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhanghongbin
 * @since 2019-11-23
 */
@Service
@DS("proxyDs")
public class ZxjEip2cZzjcServiceImpl extends ServiceImpl<ZxjEip2cZzjcMapper, ZxjEip2cZzjc> implements ZxjEip2cZzjcService {
    public Result<ZxjEip2cZzjc> updaBatch(List<ZxjEip2cZzjc> data) {
        Result<ZxjEip2cZzjc> result = new Result<ZxjEip2cZzjc>();
        if(data==null || data.size() == 0) {
            result.error500("参数不识别！");
        }else {
            for(ZxjEip2cZzjc zzjc : data){
                zzjc.setSamCurrenAmp("合格");
                zzjc.setSamCurrenPhase("合格");
                zzjc.setSamVoltageAmp("合格");
                zzjc.setSamVoltagePhsae("合格");
                zzjc.setOpenInCircuit("合格");
                zzjc.setOpenOutCircuit("合格");
                zzjc.setFunctionTest("合格");
                zzjc.setReviewStatus(Consants.REVIEW_STATUS1);
                zzjc.setProcessType(Consants.PROCESS_TYPE4);
                zzjc.setProcessRouteNo(Consants.ZZJC);
                zzjc.setIoflag(Consants.ZZJC_SP);
                zzjc.setEndTime(new Date());
            }
            super.updateBatchById(data);
            //List<String> idList = Arrays.asList(data.split(","));
            result.success("审批成功!");
        }
        return result;
    }

    @Override
    public Result<IPage<ZxjEip2cZzjc>> queryPageList(ZxjEip2cZzjc zzjc, Integer pageNo, Integer pageSize, HttpServletRequest req) {
        Result<IPage<ZxjEip2cZzjc>> result = new Result<IPage<ZxjEip2cZzjc>>();
        QueryWrapper<ZxjEip2cZzjc> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(zzjc);
        /* QueryWrapper<ZxjEip2cZzjc> queryWrapper = QueryGenerator.initQueryWrapper(zzjc, req.getParameterMap());*/
        //queryWrapper.eq("\"REVIEW_STATUS\"", Consants.REVIEW_STATUS0);
        Page<ZxjEip2cZzjc> page = new Page<ZxjEip2cZzjc>(pageNo, pageSize);
        IPage<ZxjEip2cZzjc> pageList = super.page(page, queryWrapper);
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }

}